package cn.chenfeifx.core.controls;

import cn.chenfeifx.core.common.ResourcesLoader;
import cn.chenfeifx.core.controls.skins.CFTabPaneSkin;
import javafx.beans.property.ListProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
import javafx.util.Callback;

/**
 * 基本功能已完成
 * <p>
 * 后期想法: 完成自定义标签位置功能:TOP,LEFT,RIGHT,BOTTOM
 */
public class CFTabPane extends Control {

    public CFTabPane() {
    }

    // tabs
    private final ListProperty<CFTab> tabs = new SimpleListProperty<>(FXCollections.observableArrayList());

    public ObservableList<CFTab> getTabs() {
        return tabs.get();
    }

    public ListProperty<CFTab> tabsProperty() {
        return tabs;
    }

    // TabResult
    private final ObjectProperty<Callback<CFTab, Node>> tabResult
            = new SimpleObjectProperty<>(this, "tabResult");

    public Callback<CFTab, Node> getTabResult() {
        return tabResult.get();
    }

    public ObjectProperty<Callback<CFTab, Node>> tabResultProperty() {
        return tabResult;
    }

    public void setTabResult(Callback<CFTab, Node> tabResult) {
        this.tabResult.set(tabResult);
    }

    @Override
    protected Skin<?> createDefaultSkin() {
        return new CFTabPaneSkin(this);
    }

    @Override
    public String getUserAgentStylesheet() {
        return ResourcesLoader.load("/cn/chenfeifx/core/css/cf-tab-pane.css");
    }


}
